<?php 
include('../../Connections/KRAPPERCON.php');
$oper = getVal('oper');

if ($oper == 'add'){
	$doc = getVal('documento');
	$fec = getVal('fecha');
	$mon = getVal('monto');
	$txt = getVal('texto');
	
	$sql = "call sp_doAnticipo('".$doc."','".$mon."','".$fec."','".$user_now."','".$usr_ctr."','".$txt."');";
	doEcho($sql);
	$res = $mysqli->query($sql) or die($mysqli->error.__LINE__);
	if ($res){
		if ($row = $res->fetch_assoc()){
			$newnro = $row['newnro'];
			if ($newnro>0){
				echo "<script type='text/javascript'>showOk('Anticipo ".$newnro." Registrado Correctamente');closePopup();</script>";
			}
			else {
				echo "<script type='text/javascript'>showError('".$row['msg_err']."');</script>";
			}
		}
	$res->close();
	$mysqli->check_result();
	}
}
?>